package com.digitalchina.lxnsy.toolkit;

import java.text.DecimalFormat;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.toolkit
 * 创建人：白彦东
 * 创建时间：2017/1/13 11:45
 * 修改备注：
 * ================================================
 */

public class DecimalFormatUtil {

    private static DecimalFormatUtil decimalFormatUtil;
    private DecimalFormat myFormat = new DecimalFormat();
    private String threeGroupPatter = ",##0.00";

    public static synchronized DecimalFormatUtil getInstance() {
        if (decimalFormatUtil == null) {
            decimalFormatUtil = new DecimalFormatUtil();
        }
        return decimalFormatUtil;
    }

    private String init(String pattern, String number) {
        myFormat.applyPattern(pattern);
        return myFormat.format(Double.parseDouble(number));
    }

    public String formats(String number) {
        return init(threeGroupPatter, number);
    }


}
